import 'package:boss/color_constant.dart';
import 'package:boss/provider/offers_provider.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/offersManagement/constant/offers_constant.dart';
import 'package:boss/ui/page/offersManagement/page/offersDetail/provider/offers_detail_provider.dart';
import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/buyGiftOffers/buy_gift_offers_page.dart';
import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/doubleOffers/double_offers_page.dart';
import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/fullOffers/full_offers_page.dart';
import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/orderDiscount/order_discount_page.dart';
import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/planOffers/plan_offers_page.dart';
import 'package:boss/ui/page/offersManagement/page/plusOffersMode/page/specialOffers/special_offers_page.dart';
import 'package:boss/ui/widget/button/outline_radius_button.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'offers_detail_data_card.dart';
import 'offers_detail_header.dart';

class OffersDetailBrowser extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          OffersDetailHeader(),
          OffersDetailDataCard(),
          Container(
            height: 128.w + MediaQuery.of(context).padding.bottom,
            padding: EdgeInsets.only(
              bottom: MediaQuery.of(context).padding.bottom,
            ),
            decoration: BoxDecoration(
              boxShadow: [
                DEFAULT_SHADOW,
              ],
              color: Colors.white,
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                OutlineRadiusButton(
                  title: '复 制',
                  color: ColorConstant.ffcc,
                  textStyle: TextStyleConstant().normal_1_32,
                  width: 275.w,
                  onTap: () {
                    var offersDetailProvider = Provider.of<OffersDetailProvider>(
                      context,
                      listen: false,
                    );
                    switch (offersDetailProvider.data.discountType) {
                      case OffersConstant.order_discount:
                        Navigator.pushNamed(context, OrderDiscountPage.pageName, arguments: {
                          'data': offersDetailProvider.data,
                        });
                        break;
                      case OffersConstant.double_discount:
                        Navigator.pushNamed(context, DoubleOffersPage.pageName, arguments: {
                          'data': offersDetailProvider.data,
                        });
                        break;
                      case OffersConstant.buy_gift_discount:
                        Navigator.pushNamed(context, BuyGiftOffersPage.pageName, arguments: {
                          'data': offersDetailProvider.data,
                        });
                        break;
                      case OffersConstant.special_discount:
                        Navigator.pushNamed(context, SpecialOffersPage.pageName, arguments: {
                          'data': offersDetailProvider.data,
                        });
                        break;
                      case OffersConstant.plan_discount:
                        Navigator.pushNamed(context, PlanOffersPage.pageName, arguments: {
                          'data': offersDetailProvider.data,
                        });
                        break;
                      case OffersConstant.full_discount:
                        Navigator.pushNamed(context, FullOffersPage.pageName, arguments: {
                          'data': offersDetailProvider.data,
                        });
                        break;
                      default:
                    }
                  },
                ),
                SizedBox(
                  width: 40.w,
                ),
                Consumer<OffersDetailProvider>(
                  builder: (context, offersDetailProvider, child) {
                    return OutlineRadiusButton(
                      title: offersDetailProvider.type == OffersType.over ? '删 除' : '结 束',
                      color: ColorConstant.ffcc,
                      textStyle: TextStyleConstant().normal_1_32,
                      width: 275.w,
                      onTap: () async {
                        offersDetailProvider.updateStatus();
                      },
                    );
                  },
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
